<template>
  <div>
    <div class="ly-btn-list">
      <el-button type="primary" size="small" @click="$router.push('/addpartner')">新增合作伙伴</el-button>
    </div>
    <div class="ly-table">
      <el-table :data="tableData" style="width: 100%" border>
        <el-table-column fixed prop="id" label="序号" width="100"></el-table-column>
        <el-table-column prop="bannerUrl" label="图片">
          <template slot-scope="scope">
            <img class="ly-img" :src="tableData[scope.$index].imgUrl"/>
          </template>
        </el-table-column>
        <!--        <el-table-column prop="link" label="链接"></el-table-column>-->
        <el-table-column fixed="right" label="操作" width="160">
          <template slot-scope="scope">
            <el-button size="mini" @click="getDelete(tableData[scope.$index].id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  import {findAll, partnerDelete} from "@/api/partner"

  export default {
    name: "partner",
    data() {
      return {
        tableData: []
      }
    },
    created() {
      this.findAllpartner()

    },
    methods: {
      // 删除
      getDelete(val) {
        let data = val
        partnerDelete(data).then(response => {
          console.log(response)
          let result = response.data
          if (result.code === '0000') {
            this.$message.success(result.msg)
            this.findAllpartner()
          } else {
            this.$message.error(result.msg)
          }
        })
      },
      // 所有的partner
      findAllpartner() {
        let data = {
          //appType: -1
        }
        findAll(data).then(response => {
          console.log(response)
          let result = response.data
          if (result.code === '0000') {
            this.tableData = result.data
          }
        })
      }
    }
  }
</script>

<style scoped lang="scss">

</style>